#include <iostream>
#include <pthread.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>

void* func1(void* args)
{
    struct sockaddr_in* p_addr1 = (struct sockaddr_in*)args;
    while(true)
    {
        char buffer1[INET_ADDRSTRLEN];
        const char* ptr = inet_ntop(AF_INET,&p_addr1->sin_addr,buffer1,INET_ADDRSTRLEN);
        printf("addr1 : %s\n",ptr);
        sleep(1);
    }
    return nullptr;
}

void* func2(void* args)
{
    struct sockaddr_in* p_addr2 = (struct sockaddr_in*)args;
    while(true)
    {
        char buffer2[INET_ADDRSTRLEN];
        const char* ptr = inet_ntop(AF_INET,&p_addr2->sin_addr,buffer2,INET_ADDRSTRLEN);
        printf("addr2 : %s\n",ptr);
        sleep(1);
    }
    return nullptr;
}

int main()
{
    pthread_t tid1;
    struct sockaddr_in addr1;
    struct sockaddr_in addr2;
    addr1.sin_addr.s_addr = 0;
    addr2.sin_addr.s_addr = 0xffffffff;
    pthread_create(&tid1,nullptr,func1,&addr1);

    pthread_t tid2;
    pthread_create(&tid2,nullptr,func2,&addr2);

    pthread_join(tid1,nullptr);
    pthread_join(tid2,nullptr);
    return 0;
}